from PyQt5.QtWidgets import QApplication, QWidget
from ui_test2 import Ui_Form
from pgtools.plugins.client.qtwidget_helper import TDataProxy

class MyTest(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.data_proxy = TDataProxy(self.ui.comboBox_kecheng,
                                     self.ui.lineEdit_laoshi,
                                     self.ui.textEdit_jianjie,
                                     self.ui.spinBox_keshishu,
                                     self.ui.dateEdit_kaikeshijian,
                                     )
        self.msg = TDataProxy(self.ui.label_msg, self.ui.textBrowser)

        self.default_data = {
            'comboBox_kecheng': '信息系统',
            'lineEdit_laoshi': '谢教员',
            'textEdit_jianjie':'信息系统课程简介。。。',
            'spinBox_keshishu': 60,
            'dateEdit_kaikeshijian': '2024-09-01'
        }

    def on_pushButton_pressed(self):
        print(self.data_proxy.data)
        self.msg.data = {'label_msg': '读取表单数据',
                         'textBrowser': str(self.data_proxy.data)}

    def on_pushButton_2_pressed(self):
        self.data_proxy.data = self.default_data
        self.msg.data = {'label_msg': '载入默认数据', 'textBrowser': ''}

app = QApplication([])
test = MyTest()
test.show()
app.exec_()